Update TreeAdapter to work with const inputs#1775
Update TreeAdapter to work with const inputs#1775danrbailey merged 3 commits intoAcademySoftwareFoundation:masterfrom
Conversation
… extensive unit tests Signed-off-by: Dan Bailey <danbailey@ilm.com>
Signed-off-by: Dan Bailey <danbailey@ilm.com>
|
What happens with an adapter templated on a const ValueAccessor? Or rather, is that behaviour still the same before and after this change |
The behavior before is that it fails to compile, the behavior after is that it compiles successfully. I attached a unit test with these fixes, running the unit test without the fixes results in compilation errors on these lines - 544, 546, 550, 573, 575, 577, 589, 594, 595, 604, 605, 608, 610, 611, 612, 614. Here's one example related to your question: I would expect this to work, but it results in this compile error: To extract the problematic portion of the partial specialization: You can see that calling this with This is not expected to change behavior for any method which does instantiate correctly, just fill in all the missing instantiations. |
The TreeAdapter has a few problems, most notably related to the use of the
tree()/constTree()methods. It appears that the TreeAdapter is intended to work with const inputs (because some of the typedefs remove const-ness) so it seems counter-intuitive that these methods do not always work for const inputs. In addition, the resulting error is confusing because the compiler complains about duplicate methods being defined.I created a bunch of unit tests to validate against what I considered acceptable input and modified the TreeAdapter to fix these issues.
The one area where I extended it was to explicitly add support for
TreeAdapter<const Grid<TreeT>>. This is very useful when const-ness is baked into an input template argument and seemed consistent with supportingTreeAdapter<const TreeT>.All of the rest of the unit tests pass and none of these changes are expected to affect compatibility.
(@kmuseth)